<?php
// +----------------------------------------------------------------------
// | 十分彩网系统 [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Tuolaji <479923197@qq.com>
// +----------------------------------------------------------------------
/**
 */
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
header('Content-type:text/html;charset=utf-8');


class MsgController extends AdminbaseController{
	
	protected $users_model,$role_model;
	
    public function _initialize() {
        parent::_initialize();
    }

    //会员管理列表
    public function index(){
    	$where=array();
        $request=I('request.');
				
        if(!empty($request['subject'])){
            $where['g.subject']=$request['subject'];
            $this->assign("subject",$request['subject']);
        }
        if(!empty($request['title'])){
        	$where['g.title']=$request['title'];
        	$this->assign("title",$request['title']);
        }
        if(!empty($request['member_id'])){
        	$where['g.member_id']=$request['member_id'];
        	$this->assign("member_id",$request['member_id']);
        }
        
        $count = M('msgcon')
		->table('sp_msgcon g')
		->join("sp_member m on g.member_id = m.id")
		->field("g.*")
        ->where($where)->count();
        $size = $page = $this->page($count, 25);
        
        $data = M('msgcon')
		->table('sp_msgcon g')
		->join("sp_member m on g.member_id = m.id")
		->field("g.*")
        ->where($where)
        ->order("create_time DESC,id DESC")
        ->limit($page->firstRow, $page->listRows)
        ->select();
        if(!empty($data) && is_array($data)){
        	$existdata=true;
        }else{
        	$existdata=false;
        }
        $this->assign("page", $page->show('Admin'));
        $this->assign("msgcon", $data);
        $this->assign("existdata", $existdata);
        $this->display();
        
    }
    
    public function edit(){
    	$id = I('get.id',0,'intval');
    	$item = M("msgcon")
		->where("id='$id'")
		->find();
    	$this->assign("msgcon", $item);
    	$this->display();
    }
	public function delete(){
		$id = I("get.id",0,"intval");
		if (M('msgcon')->where(array("id"=>$id))->delete()!==false) {
			$this->success("删除成功！");
		} else {
			$this->error("删除失败！");
		}
	}
}//结束
?>